
#include <opencv2/opencv.hpp>

#include "task/srgan.h"
#include "utils/logging.h"

int main(int argc, char **argv)
{
    
    // model file path
    const char *model_file = argv[1];
    // input img path
    const char *img_file = argv[2];
    // 读取图片
    // cv::Mat img = cv::imread(img_file, cv::IMREAD_GRAYSCALE);
    cv::Mat img = cv::imread(img_file);
    // 放大成1280x1280
    cv::Mat img_resized;
    cv::resize(img, img_resized, cv::Size(1280, 1280));
    // 保存结果
    cv::imwrite("resized.jpg", img_resized);

    cv::cvtColor(img, img, cv::COLOR_BGR2RGB);

    // 初始化
    SRGAN srgan;
    // 加载模型
    srgan.LoadModel(model_file);

    cv::Mat result_img;
    // 计算整体耗时
    auto start = std::chrono::high_resolution_clock::now();
    // 运行模型
    srgan.Run(img, result_img);

    // 计算耗时
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> duration = end - start;
    std::cout << "Total time: " << duration.count() << " ms" << std::endl;
    // 保存结果
    cv::imwrite("result.jpg", result_img);

    return 0;
}